/*
 * @(#)JCGFilter.java        0.1 09/04/29
 * @version 	0.1 29 Apr 2009
 * @author Do Van Khang
 * 
 * Loc cac file cua chuong trinh (*.jcg)
 */


package GUI;

import java.io.File;
import java.util.ResourceBundle;

import javax.swing.filechooser.*;

public class JCGFilter extends FileFilter {
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String extension = getExtension(f);
        if (extension != null) {
            if (extension.equals("jcg")) {
                    return true;
            } else {
                return false;
            }
        }

        return false;
    }

    public String getDescription() {
    	ResourceBundle lang = Options.getLanguage();
        return lang.getString("FileChooser.fileExtension.JCG");
    }

    /*
     * Lay phan mo rong cua 1 file
     */
    public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
}

class FolderFilter extends FileFilter {
	public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        } else return false;
    }
	
    public String getDescription() {
    	ResourceBundle lang = Options.getLanguage();
        return "Folder";
    }
}